﻿Imports DTO
Imports System.Data.OleDb

Public Class KhachHangDAO
    Public Function LayKHTheoCN(ByVal maKH As Integer) As List(Of KhachHangDTO)
        Dim sql = "select * from KhachHang where MaKH = " & maKH
        Dim conn As OleDbConnection = DataProvider.ConnectDB()
        Dim cmd As New OleDbCommand(sql, conn)
        Dim reader As OleDbDataReader = cmd.ExecuteReader()
        Dim danhsach As New List(Of KhachHangDTO)
        While reader.Read()
            Dim khDTO As New KhachHangDTO()
            khDTO.MaKH = reader.GetInt32(0)
            khDTO.TenKH = reader.GetString(1)
            khDTO.GioiTinh = reader.GetString(2)
            khDTO.CMND = reader.GetString(3)
            khDTO.NgaySinh = reader.GetDateTime(4)
            khDTO.DiaChi = reader.GetString(5)
            khDTO.MaCN = reader.GetInt32(6)

            danhsach.Add(khDTO)
        End While
        conn.Close()
        Return danhsach
    End Function
End Class
